
from Controller import Controller
# map mgr
from Cube.map import MapMgrGet
# cmd
from Cube.command.QCommand import QCmdGameRun

class ServerController(Controller):
    def __init__(self):
        Controller.__init__(self)
        self.TotalMemberNum = len( MapMgrGet().CurrentMapHeader.MemberList )
        self.MemberCnt = 0


    # override it
    def _InitializeDoneReply(self, memberID):
        self.MemberCnt += 1
        # start the game after receive all CmdInitializeDone of members
        if self.MemberCnt == self.TotalMemberNum:
            QCmdGameRun().Send()

    def _MapBodyLoad(self):
        Controller._MapBodyLoad(self)
        MapMgrGet().CurrentMapBody.AmIServer = True